#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;
const int MOD = 10007;

ll n;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string s;
  cin >> s;
  for (char c : s) n = (n * 10 + c - '0') % MOD;
  ll ans = n * (n + 1) % MOD * (n + 2) % MOD * ((MOD + 1) / 6) % MOD;
  cout << ans;
  return 0;
}